<?php
class User_Model_Bill extends Zend_Db_Table{
	protected $_name = 'bill';
	protected $_primary = 'bill_id';
	/* Link tham khao : http://framework.zend.com/manual/en/zend.db.table.html */
	/* select demo */
	
	// them thong tin payment vao bill
	public function insertBill($data)
	{// co dung
		$data['route'] = "insertBill";
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restPost("/bill", $data);

		return $return->getBody();
	}
	
	//lay thong tin bill theo user id
	public function getBillByUserId($id)
	{// co dung
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restGet("/bill/route/getBillByUserId/id/".$id);
		$return = json_decode(json_encode((array) simplexml_load_string($return->getBody())),1);
		
		for ($i=0;$i <count($return);$i++)
				$data[$i] = $return['row_'.$i];
				
		return $data;
	}
	
	//lay thong tin bill theo bill id
	public function getBillByBillId($id)
	{// co dung
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restGet("/bill/route/getBillByBillId/id/".$id);
		$return = json_decode(json_encode((array) simplexml_load_string($return->getBody())),1);
		
		for ($i=0;$i <count($return);$i++)
				$data[$i] = $return['row_'.$i];
				
		return $data;
	}
}